package com.yocard.yxyd.ui.presenter;

import com.yocard.yxyd.base.CommonSubscriber;
import com.yocard.yxyd.base.RxPresenter;
import com.yocard.yxyd.http.HttpManager;
import com.yocard.yxyd.http.model.response.CoinsBean;
import com.yocard.yxyd.ui.contract.TransContract;
import com.yocard.yxyd.utils.RxUtil;

import java.util.List;

import javax.inject.Inject;

/**
 * Created on 2019/4/17.
 */
public class TransPresenter extends RxPresenter<TransContract.View> implements TransContract.Presenter {

    @Inject
    public TransPresenter(HttpManager manager) {
        super(manager);
    }

    @Override
    public void fetchList(int page, String type) {
        addSubscribe(httpManager.getCoinsTrans(page,type).compose(RxUtil.rxSchedulerHelper()).subscribeWith(new CommonSubscriber<List<CoinsBean>>(mView) {
            @Override
            public void onSuccess(List<CoinsBean> data) {
                try {
                    mView.onFetchList(data);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }));
    }
}
